package net.fkzg.framework.application.dingtalk;

import com.alibaba.fastjson2.JSONObject;
import net.fkzg.framework.util.HttpUtil;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DingTalkHelper {

    public static void sendMsgToDingTalk(String webhook,String keyword,String title,String content) {
        JSONObject json = new JSONObject();
        json.put("msgtype","text");
        JSONObject text = new JSONObject();
        text.put("content",keyword + ":"+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))+"\n" + title + "\n"+ content);
        json.put("text",text);
        HttpUtil.sendPostJson(webhook,json.toJSONString());
    }

}
